<script type="text/html" data-help-name="流开关">
    <p>流开关节点：用于数据流的通行管理</p>
</script>
  
  


<script type="text/html" data-template-name="流开关">
    <!-- 设置第一行为Name -->
    <div class="form-row">
      <label for="node-input-name"><i class="fa fa-tag"></i> 名称</label>
      <input type="text" id="node-input-name" data-i18n="[placeholder]name">
  </div>

  <div class="form-row" id="node-set-tick">
    <label>&nbsp;</label>
    <input type="checkbox" id="node-input-set" style="display: inline-block; width: auto; vertical-align: top;">
    <label for="node-input-set" style="width: 70%;">流开关-初始化</label>
  </div>
  <div class="form-row" id="node-set-state">
    <label for="node-input-flowSwitch">&nbsp;</label>
    <select id="node-input-flowSwitch" style="width: 250px;">
      <option value="on">打开</option>
      <option value="off">关闭</option>
      </select>
  </div>
  
  </script>
  
  
  
  <script type="text/javascript">
      RED.nodes.registerType('流开关',{
        category: 'Block 通用节点',
        color: '#35c1f4',
        defaults: {
          name: {value:""},
          set: { value:"" },
          flowSwitch: {value:"on"},
        },
        inputs:1,
        outputs:1,
        icon: "ui_switch.png",
        label: function() {
          return this.name||this._("流开关节点");
        },
        inputLabels: function(i) {
          return this.name||this._("输入-任意流均可触发或msg.payload.switch=on/off");
        },
        outputLabels: function(i) {
          return this.name || this._("输出-原样输出输入的流");
        },

        oneditprepare: function() {

            var setstate = function () {
                if ($('#node-input-set').is(":checked")) {
                    $("#node-set-state").show();
                } else {
                    $("#node-set-state").hide();
                }
            };
            $("#node-input-set").change(function () { setstate(); });
            setstate();
        }
  
      });
    </script>
    
